#! /usr/bin/env python
#Nz9fZ2VT4Sh8

import roslib; roslib.load_manifest('people_recognition')
import rospy, time
import actionlib


from people_recognition.msg import *

def PeopleRecognitionClient(string_input):
	rospy.logwarn('Starting Client...')
	client = actionlib.SimpleActionClient('recognition_server', PersonAction)
	rospy.logwarn('Waiting on server...')
	client.wait_for_server()
	rospy.logwarn('Found Server...')

	#time.sleep(15)
	goal = PersonGoal()
	goal.image = string_input
	client.send_goal(goal)
	rospy.logwarn('Sending Goal...')
	client.wait_for_result()

	result=client.get_result()
	people_found = ""
	for person in result.people:
		people_found = people_found + "Person "+str(person.identifier)+":\n"
		people_found = people_found + "Face Center: "+str(person.z)+"\n"
		people_found = people_found + "Shirt Color (rgb): " + str(person.shirt_red) + " "+str(person.shirt_green) + " "+str(person.shirt_blue)+"\n"
		people_found = people_found + "Face Color (rgb): " + str(person.face_red) + " "+str(person.face_green) + " "+str(person.face_blue)
	rospy.logwarn(people_found)
	rospy.logwarn('Finished!\n')

if __name__ == '__main__':
	rospy.init_node('recognition_client')
	PeopleRecognitionClient("some-string-here")
